Skip to content

Conversation

ap0nia
Copy link
Contributor

@ap0nia ap0nia commented Aug 4, 2024

The queries property in the first argument provided to createQueries should have the readonly modifier.

Minimum Reproduction

import { createQueries, type QueriesOptions } from '@tanstack/svelte-query'

const a = [] as readonly QueriesOptions<any>[]

// @ts-expect-error type readonly any[] is not assignable...
createQueries({ queries: a })

Expectation

A readonly QueriesOptions<any>[] and variations of this type should be compatible with the createQueries function signature.

Context

I'm writing a utility function that generates strongly typed query options, which will be plugged into createQueries directly. It looks something like this:

function createTypedQueryOptions<T>(options: T): readonly [...QueriesOptions<T>] {}

The main points being that the function is generic, and returns a readonly tuple with strongly typed query options that are derived from the input generic. However, the readonly modifier is currently not compatible when using createQueries because the queries property is missing it...

Other APIs

This is based on the types exported from react-query's useQueries, as well as solid-query's createQueries.

Copy link

nx-cloud bot commented Aug 4, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d7b9a05. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

Copy link

codesandbox-ci bot commented Aug 4, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d7b9a05:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

Copy link

pkg-pr-new bot commented Aug 4, 2024

commit: d7b9a05

pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@7848
pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@7848
pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@7848
pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@7848
pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@7848
pnpm add https://pkg.pr.new/@tanstack/query-core@7848
pnpm add https://pkg.pr.new/@tanstack/query-devtools@7848
pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@7848
pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@7848
pnpm add https://pkg.pr.new/@tanstack/react-query@7848
pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@7848
pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@7848
pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@7848
pnpm add https://pkg.pr.new/@tanstack/solid-query@7848
pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@7848
pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@7848
pnpm add https://pkg.pr.new/@tanstack/svelte-query@7848
pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@7848
pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@7848
pnpm add https://pkg.pr.new/@tanstack/vue-query@7848
pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@7848

Open in Stackblitz

More templates

Copy link

codecov bot commented Aug 4, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.27%. Comparing base (93674fe) to head (d7b9a05).
⚠️ Report is 1251 commits behind head on main.

❌ Your project status has failed because the head coverage (88.27%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #7848       +/-   ##
===========================================
+ Coverage   41.42%   88.27%   +46.84%     
===========================================
  Files         184       18      -166     
  Lines        7331      162     -7169     
  Branches     1531       32     -1499     
===========================================
- Hits         3037      143     -2894     
+ Misses       3889       16     -3873     
+ Partials      405        3      -402     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental ∅ <ø> (∅)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister ∅ <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core ∅ <ø> (∅)
@tanstack/query-devtools ∅ <ø> (∅)
@tanstack/query-persist-client-core ∅ <ø> (∅)
@tanstack/query-sync-storage-persister ∅ <ø> (∅)
@tanstack/react-query ∅ <ø> (∅)
@tanstack/react-query-devtools ∅ <ø> (∅)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client ∅ <ø> (∅)
@tanstack/solid-query ∅ <ø> (∅)
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client ∅ <ø> (∅)
@tanstack/svelte-query 87.33% <ø> (+24.64%) ⬆️
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client 100.00% <ø> (ø)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TkDodo
Copy link
Collaborator

TkDodo commented Aug 19, 2025

as I’m looking through stale PRs and seeing this one has conflicts, I’m gonna go ahead and close it and would like you to re-open a new PR with a type-level test that shows what this improvement does and also confirms that no existing usage will break.

thank you 🙏

@TkDodo TkDodo closed this Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants